import { useTable } from '@/hooks/useTable'
import type { Ref } from 'vue'

export const PLATFORM_LIST_KEY = 'PLATFORM_LIST_KEY'

export interface PlatformItem {
  id?: string
  name: string
  code: string
  remarks?: string
}

export const DEFAULT_PLATFORM_LIST: PlatformItem[] = [
  {
    name: '且慢',
    code: 'wait-a-minute',
    remarks: '场外基金，自动记录份额'
  },
  {
    name: '华宝',
    code: 'war-burg',
    remarks: '场内，交易费低，实时价格'
  },
  {
    name: '支付宝',
    code: 'alipay',
    remarks: '一般放现金'
  },
  {
    name: '微信',
    code: 'wechat',
    remarks: '一般放现金'
  },
  {
    name: '招行',
    code: 'cmb',
    remarks: '一般放现金'
  }
]

export const initPlatform = () => {
  const { list } = useTable<PlatformItem>({
    cacheKey: PLATFORM_LIST_KEY,
    defaultList: DEFAULT_PLATFORM_LIST
  }) as { list: Ref<PlatformItem[]> }

  return {
    list
  }

}